package domain.general;

import technicalservices.database.PersistanseStorage;
import domain.users.User;

public class Login {

	public User authenticate(String email, String password) {
		System.out.println("Entered: " + email + " " + password);
		if (PersistanseStorage.getInstance().checkPassword(email, password)) {
			String[] userData = PersistanseStorage.getInstance().getUser(email);

			if (userData != null) {
				return new User(Integer.parseInt(userData[0]), userData[3], userData[1], userData[4]);
			}
		}
		return null;
	}

	public boolean userExists(String email) {
		String[] user = PersistanseStorage.getInstance().getUser(email);
		return user != null;
	}

}
